﻿<%@ Register TagPrefix="cnt" Namespace="Mysoft.Map.Application.Controls" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WF_ProcessCommonModule.aspx.vb"
    Inherits="MyWorkflow.WF_ProcessCommonModule" EnableViewState="false" %>

<html>
<head>
    <title>定义我的常用流程</title>
    <link href="/_nav/menu.css" type="text/css" rel="stylesheet">

    <script language="javascript" src="/_forms/FormBase.js"></script>

    <script language="javascript" src="/_controls/settings.aspx"></script>

    <script language="javascript" src="/_controls/datetime/date.js"></script>

    <script language="javascript" src="/_controls/datetime/time.js"></script>

    <script language="javascript" src="/_controls/number/number.js"></script>

    <script language="javascript" src="/_controls/lookup/map_lookup.js"></script>

    <script language="javascript" src="/_controls/lookup/LookupDialogs.js"></script>

    <script language="javascript" src="/_controls/lookup/selectteamuser.js"></script>

    <script language="javascript" src="/_common/scripts/Details.js"></script>

    <script language="javascript" src="/_controls/util/util.js"></script>

    <script language="javascript" src="/_grid/rep_grid.js"></script>

    <script language="javascript" src="/MyWorkflow/Workflow.js"></script>

    <script language="javascript" src="/_common/scripts/global.js"></script>

    <script language="javascript" src="/_nav/menu.js"></script>

    <link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
    <link rel="stylesheet" type="text/css" href="/_nav/taskbox.css">
    <link rel="stylesheet" type="text/css" href="/_nav/menu.css">
    <link rel="stylesheet" type="text/css" href="/_forms/styles/form.css">

<script type="text/javascript">
window.onload = function()
{
	if(document.all("table1"))
	{ 
		initGrid(table1);
	}
	if(document.all("table2"))
	{
		initGrid(table2);
	}
}
function getData()
{
    var tb=document.getElementById("table1");
    var tb2=document.getElementById("table2");
    var ishave;
    var orderID;
    var dataXml='<rows>';
    for(var i=0;i<tb.rows.length;i++)
    {
        if(tb.rows[i].ishave=="1")
        {
            ishave="1";
        }
        else
        {
            ishave="0";
        }
        orderID=0;
        for(var j=0;j<tb2.rows.length;j++)
        {
            if(tb.rows[i].oid==tb2.rows[j].oid)
            {
                orderID=j+1;
                break;
            }
        }
        dataXml+='<row ProcessGUID="'+tb.rows[i].oid+'" ishave="'+ishave+'" orderID="'+orderID+'" />';
    }
    dataXml+="</rows>";
    return dataXml;
}

function okClick()
{
    var returnText = GetDataFromXMLHTTP("/MyWorkflow/WF_XmlHTTP.aspx","SaveProcessCommon","","",getData());
    if(returnText == "success")
	{
		alert("保存成功！");
	}
	else
	{
		alert("保存失败！");
	}
	window.returnValue = returnText;
	window.close();
}
function appendSelected(o)
{
    appendAdd(o);
}
function appendUnSelected(o)
{
    appendDel(o);
}

function seek()
{
    var keyword=document.getElementById("txt1").value;
    var tb=document.getElementById("table1");
    var arrRows=tb.rows;
    var tr;
    if(keyword=="" || keyword ==String.empty)
    {
        for(var i=0;i<arrRows.length;i++)
        {
           tr=arrRows[i];
           tr.style.display='block';
        }
        return;
    }
    var mbname;
    var reg;
    for(var i=0;i<arrRows.length;i++)
    {
        tr=arrRows[i];
        mbname=tr.value;
        //reg=new RegExp(keyword);
        //if(!reg.test(mbname))
        if(mbname.indexOf(keyword) == -1)
        {
            tr.style.display="none";
        }else{
            tr.style.display="block";
        }
    }
}
function appendChoose(o)
{
    if(o.ischoose=="0")
    {
        o.ischoose="1";
        o.style.backgroundColor="#CAD3E4";
    }
    else
    {
        if(o.parentNode.id!="table1")
        {
            o.ischoose="0";
            o.style.backgroundColor="white";
        }
    }
}
function appendAdd(tr)
{
    var arrRows=[];
    var tb=document.getElementById("table1");
    if(tr==null)
    {
        var j=0;
        for(var i=0;i<tb.rows.length;i++)
        {
            if(tb.rows[i].ischoose=="1")
            {
                arrRows[j]=tb.rows[i];
                j++;
            }
        }
    }
    else
    {
        arrRows[0]=tr;
    }
    var tb2=document.getElementById("table2");
    for(var j=0;j<arrRows.length;j++)
    {
        var k=0;
        for(var i=0;i<tb2.rows.length;i++)
        {
            if(tb2.rows[i].oid==arrRows[j].oid)
            {
                k=1;
                break;
            }
        }
        if(k==0)
        {
            var tr=tb2.insertRow(-1);
            tr.oid=arrRows[j].oid;
            tr.value=arrRows[j].value;
            tr.ondblclick=function(){appendUnSelected(this);};
            tr.onmouseover=function(){this.bgColor="#E3E9F4";};
            tr.onmouseout=function(){this.bgColor="#ffffff";};
            tr.onclick=function(){appendChoose(this);};
            tr.style.cursor='pointer';
            tr.ischoose="0";
            var td=document.createElement("td");
            td.innerHTML = arrRows[j].value;
            td.title = arrRows[j].value; //BUG 45499 添加提示 sunfx 2009年5月7日15:27:06 END
            td.style.paddingLeft='9px';
            td.style.height = '21px';
            td.style.whiteSpace = "nowrap";//BUG 45499 添加样式 sunfx 2009年5月7日15:27:06 END
            tr.appendChild(td);
        }
    }
    for(var i=0;i<arrRows.length;i++)
    {
        appendChoose(arrRows[i]);
        if(arrRows[i].ishave=="0"||arrRows[i].ishave=="")
        {
            ishaveChange(arrRows[i]);
        }
    }
}

function appendDel(tr)
{
    var arrRows=[];
    var tb2=document.getElementById("table2");
    var tb=document.getElementById("table1");
    if(tr==null)
    {
        for(var i=0;i<tb2.rows.length;i++)
        {
            if(tb2.rows[i].ischoose=="1")
            {
                arrRows[i]=tb2.rows[i];
            }
        }
    }
    else
    {
        for(var i=0;i<tb2.rows.length;i++)
        {
            if(tb2.rows[i].oid==tr.oid)
            {
                arrRows[i]=tb2.rows[i];
            }
        }
    }
    for(var i=arrRows.length-1;i>=0;i--)
    {
        if(arrRows[i]!=null)
        {
            tb2.deleteRow(i);
            for(var j=0;j<tb.rows.length;j++)
            {
                if(arrRows[i].oid==tb.rows[j].oid)
                {
                    ishaveChange(tb.rows[j]);
                }
            }
        }
    }
}
function ishaveChange(o)
{
    if(o.ishave=="0"||o.ishave=="")
    {
        o.ishave="1";
        o.childNodes[0].style.color='#C3C3B4';
    }
    else if(o.ishave=="1")
    {
        o.ishave="0";
        if(o.childNodes[0].firstChild.nodeName=="FONT")
        {
            o.childNodes[0].firstChild.style.color='black';
        }
        o.childNodes[0].style.color='black';
    }
}

function moveDown()
{
    var tb2=document.getElementById("table2");
    var arrRows=[];
    for(var i=tb2.rows.length-1;i>=0;i--)
    {
        if(tb2.rows[i].ischoose=="1" && i<tb2.rows.length-1)
        {
            for(var j=tb2.rows.length-1;j>i;j--)
            {
                if(tb2.rows[j].ischoose!="1"){ break; }
            }
            if(j==i) continue;
            moveOne(tb2.rows[i+1],tb2.rows[i]);
        }
    }
}

function moveUp()
{
    var tb2=document.getElementById("table2");
    var arrRows=[];
    for(var i=0;i<tb2.rows.length;i++)
    {
        if(tb2.rows[i].ischoose=="1" && i>0)
        {
            for(var j=0;j<i;j++)
            {
                if(tb2.rows[j].ischoose!="1"){ break; }
            }
            if(j==i) continue;
            moveOne(tb2.rows[i-1],tb2.rows[i]);
        }
    }
}

function moveOne(tr1,tr2)
{
    var oid1,oid2;
    var value1,value2;
    var innerText1,innerText2;
    var ischoose1,ischoose2;
    var bgColor1,bgColor2;
    oid1=tr1.oid;
    oid2=tr2.oid;
    value1=tr1.value;
    value2=tr2.value;
    innerText1=tr1.innerText;
    innerText2=tr2.innerText;
    ischoose1=tr1.ischoose;
    ischoose2=tr2.ischoose;
    bgColor1=tr1.style.backgroundColor;
    bgColor2=tr2.style.backgroundColor;
    tr1.oid=oid2;
    tr1.value=value2;
    tr1.firstChild.innerText=innerText2;
    tr1.ischoose=ischoose2;
    tr1.style.backgroundColor=bgColor2;
    tr2.oid=oid1;
    tr2.value=value1;
    tr2.firstChild.innerText=innerText1;
    tr2.ischoose=ischoose1;
    tr2.style.backgroundColor=bgColor1;
}
    </script>

</head>
<body ms_positioning="GridLayout" style="padding:10px">
        <form id="mapForm" method="post" runat="server">
        <asp:TextBox ID="txtMyModules" Style="display: none" runat="server"></asp:TextBox>
        <table style="table-layout: fixed;" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tr>
                <td style="vertical-align: top; height:100%;width:45%">
                        <table cellspacing="0" cellpadding="0" border="0" width="100%" style="vertical-align: top">
                            <tr style="vertical-align: top; height: 26px;">
                                <td align="center">
                                <table width="100%">
                                    <tr>
                                        <td>模板名称：</td>
                                        <td width="55%"><input type="text" id="txt1" style="width:100%" onkeyup="seek()"/></td>
                                        <td><input type="button" id="btn1" value="查找" onclick="seek()" style="width: auto" /></td>
                                    </tr>
                                </table>
                                </td>
                            </tr>
                            <tr>
                                <td class="wizbox1" vAlign="top" align="center">
                                    <div style="OVERFLOW: auto; WIDTH: 100%; HEIGHT: 400px">
                                        <cnt:Repeater ID="rep1" runat="server" EnablePager="false" FooterCssClass="footer"
                                            LinkCssClass="a1" LinkAlign="right" SortSignASC='<img src="/_imgs/ico_arrow_u.gif">'
                                            SortSignDESC='<img src="/_imgs/ico_arrow_d.gif">'>
                                            <HeaderTemplate>
                                                <table id="table1" onclick="handleClick();" cellspacing="0" cellpadding="0" border="1"
                                                    style="width: 100%; table-layout: fixed; border-collapse: collapse;background-color: #ffffff;" width="100%" MultiSelect="true">
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <tr height='21' style="cursor: pointer;" oid='<%# DataBinder.Eval(Container, "DataItem.GUID") %>'
                                                    value='<%# DataBinder.Eval(Container, "DataItem.Name") %>' is_hide="false" ondblclick="appendSelected(this);" onmouseover='this.bgColor="#E3E9F4"' onmouseout='this.bgColor="#ffffff"' onclick="appendChoose(this);"
                                                    ischoose="0" allowselect='1' ishave='<%# DataBinder.Eval(Container, "DataItem.ishave") %>'>
                                                    <td style="padding-left: 9px; vertical-align:middle;" nowrap>
                                                        <%#DataBinder.Eval(Container, "DataItem.showHTML")%>
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                </table>
                                            </FooterTemplate>
                                        </cnt:Repeater>
                                    </div>
                                </td>
                            </tr>
                        </table>
                </td>
                <td style="text-align: center">
                    <table width="100%;" style="text-align: center;">
                        <tr>
                            <td>
                                <input type="button" id="btnAdd();" value=">>" style="width: auto;" onclick="appendAdd()" />
                            </td>
                        </tr>
                        <tr height="20">
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="button" id="btnDel();" value="<<" style="width: auto;" onclick="appendDel()" />
                            </td>
                        </tr>
                    </table>
                </td>
                <td vAlign="top" align="center" width="45%">
                        <table height="100%" cellSpacing="0" cellPadding="0" width="100%">
                            <tr height="1">
                                <td>
                                    <mnu:AppGridMenu ID="appGridMenu" runat="server"></mnu:AppGridMenu>
                                </td>
                            </tr>
                            <tr>
                                <td class="wizbox1" style="vertical-align: top">
                                <div style="OVERFLOW: auto; WIDTH: 100%; HEIGHT: 100%;">
                                        <cnt:Repeater ID="rep2" runat="server" EnablePager="false" FooterCssClass="footer"
                                            LinkCssClass="a1" LinkAlign="right" SortSignASC='<img src="/_imgs/ico_arrow_u.gif">'
                                            SortSignDESC='<img src="/_imgs/ico_arrow_d.gif">'>
                                            <HeaderTemplate>
                                                <table id="table2" cellspacing="0" cellpadding="0" border="1" style="                           width: 100%; table-layout: fixed; border-collapse: collapse;background-color: #ffffff;" width="100%"
                                                    MultiSelect="true">
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <tr height='21' style="cursor: pointer;" oid='<%# DataBinder.Eval(Container, "DataItem.GUID") %>'
                                                    value='<%# DataBinder.Eval(Container, "DataItem.Name") %>' ondblclick="appendUnSelected(this);"
                                                    onmouseover='this.bgColor="#E3E9F4"' onmouseout='this.bgColor="#ffffff"' onclick="appendChoose(this);" ischoose="0" allowselect='1' is_hide="false" >
                                                    <td style="padding-left: 9px; vertical-align:middle;" nowrap title='<%#DataBinder.Eval(Container, "DataItem.Name")%>'><%--BUG 45499 添加TITLE sunfx 2009年5月7日15:27:06 END--%>
                                                        <%#DataBinder.Eval(Container, "DataItem.Name")%>
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                </table>
                                            </FooterTemplate>
                                        </cnt:Repeater>
                                        </div>
                                </td>
                            </tr>
                        </table>
                </td>
            </tr>
            <tr>
                <td align="right" colspan="3" height="40px">
                    <input type="button" style="width: auto" id="btnOk" onclick="okClick();" value="确 定" />&nbsp;&nbsp;
                    <input type="button" style="width: auto" onclick="parent.window.close();" value="取 消" />&nbsp;&nbsp;
                </td>
            </tr>
        </table>
        </form>
</body>
</html>
